<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<base href="<%=basePath%>">
<html lang="zn-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="format-detection" content="telephone=no"/>
    <title>卡信息</title>

</head>
<body>
<input type="hidden" id="openid" value="${openid}"/>
<span id="test"></span>
<img id="testImg" alt="" src="">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>

<script type="text/javascript">
    wx.config({
        debug: false,
        beta: true,
        appId: '${wxconfig.appid}', // 必填,公众号的唯一标识
        timestamp: ${wxconfig.timestamp}, // 必填,生成签名的时间戳
        nonceStr: '${wxconfig.noncestr}', // 必填,生成签名的随机串
        signature: '${wxconfig.signature}',// 必填,签名,详见微信JS-SDK说明文档
        jsApiList: [
            'checkJsApi',
            'nfcIsConnect',
            'nfcConnect',
            'nfcBatchTransceive'
        ]
    });

    wx.ready(function () {
        // 判断当前客户端版本是否支持指定JS接口
        /*  	    	wx.checkJsApi({
                         jsApiList: ['getNetworkType', 'chooseImage'], // 需要检测的JS接口列表，所有JS接口列表见附录2,
                         success: function(res) {
                             // 以键值对的形式返回，可用的api值true，不可用为false
                             // 如：{"checkResult":{"chooseImage":true, "getNetworkType":true},"errMsg":"checkJsApi:ok"}
                             $('#test').text(JSON.stringify(res));
                         }
                     }); */

        wx.chooseImage({
            count: 1, // 默认9
            sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
            sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
            success: function (res) {
                var localIds = res.localIds; // 返回选定照片的本地ID列表，localId可以作为img标签的src属性显示图片
                $('#test').text(localIds);
                $('#testImg').attr('src', localIds);
            }
        });

        wx.getNetworkType({
            success: function (res) {
                var networkType = res.networkType; // 返回网络类型2g，3g，4g，wifi
                //$('#test').text(networkType);
            }
        });

    });

    wx.error(function (res) {

    });

</script>

</body>
</html>